import request from '@/utils/request';
import { AuthFieldType, Certificate, LoginParams, UserInfo } from '@/type/userType';
import type { Response } from '@/type/ResponseType';

enum Enum {
  userLoginAPI = '/user/login',
  getCodeAPI = '/sms/send',
  fetchUserInfoAPI = '/user/auth/getUserInfo',
  fetchCertificatesTypeAPI = '/cmn/dict/findByDictCode/CertificatesType',
  authUserAPI = '/user/auth/userAuah'
}

/**
 *
 * @description 登录的接口
 * */

export const userLoginAPI = (data: LoginParams) => request.post<UserInfo, Response<UserInfo>>(`${Enum.userLoginAPI}`, data);


/**
 *
 * @description 获取验证码的接口
 * */

export const getCodeAPI = (phone: string) => request.get<string, Response<string>>(`${Enum.getCodeAPI}/${phone}`);


/**
 * @description 获取用户信息的接口
 * */
export const fetchUserInfoAPI = () => request.get(`${Enum.fetchUserInfoAPI}`);

/**
 * @description 获取证件类型的接口
 * */

export const fetchCertificatesTypeAPI = () => request.get<Certificate, Response<Certificate[]>>(Enum.fetchCertificatesTypeAPI);


/* 用户实名认证的接口 */
export const authUserAPI = (data: AuthFieldType) => request.post(Enum.authUserAPI,data);

